/**
 * Main类
 * @author lufy
 * @blog http://blog.csdn.net/lufy_Legend
 * @email lufy.legend@gmail.com
 **/
LSystem.screen(LStage.FULL_SCREEN);

function doScroll() {
	if(window.pageYOffset === 0)return;
	window.scrollTo(0, 1);
}
window.onload = function() {
	setTimeout(doScroll, 100);
	init(50,"legend",800,450,main,LEvent.INIT);
};
window.onorientationchange = function() {
	setTimeout(doScroll, 100);
};
window.onresize = function() {
	setTimeout(doScroll, 100);
};
var loadingLayer;
var stageLayer;
var backLayer;
var listLayer;
var cityLayer;
var characterLayer;
var selectLayer;
var selectedLayer;
var ctrlLayer;
var loadData = [
//UI
{path:"../lufylegend.ui-0.1.0.min.js",type:"js"},
{path:"./js/GameBody.js",type:"js"},
{path:"./js/GameLogo.js",type:"js"},
//共通
{path:"./js/Common/Utils.js",type:"js"},
{path:"./js/Common/Face.js",type:"js"},
//游戏数据
{path:"./js/Data/CharacterList.js",type:"js"},
{path:"./js/Data/Monarch.js",type:"js"},
{path:"./js/Data/mapData.js",type:"js"},
//选择势力
{path:"./js/Select/SelectMap.js",type:"js"},
{path:"./js/Select/SelectMapEvent.js",type:"js"},
//内政相关
{path:"./js/InternalAffairs/InternalAffairsMap.js",type:"js"},
{path:"./js/InternalAffairs/City.js",type:"js"},
{path:"./js/InternalAffairs/CharacterProperty.js",type:"js"},
{path:"./js/InternalAffairs/CharacterView.js",type:"js"},
{path:"./js/InternalAffairs/InternalAffairsMapEvent.js",type:"js"},
{path:"./js/InternalAffairs/InternalAffairsUtils.js",type:"js"},
//战斗相关
{path:"./js/Atk/Character.js",type:"js"},
{path:"./js/Atk/AtkMap.js",type:"js"},
{path:"./js/Atk/AtkMapEvent.js",type:"js"},
{path:"./js/Atk/AtkMapCtrl.js",type:"js"},
{path:"./js/Atk/AtkUtils.js",type:"js"},

{name:"logo",path:"./images/logo.jpg"},

{name:"1-0",path:"./images/1-0.png"},
{name:"1-1",path:"./images/1-1.png"},
{name:"1-2",path:"./images/1-2.png"},
{name:"1-3",path:"./images/1-3.png"},
{name:"face",path:"./images/face.png"},
{name:"characterBox",path:"./images/characterBox.png"},
{name:"bigmap",path:"./images/bigmap.png"},
{name:"minimap",path:"./images/minimap.png"},
{name:"nameBtn",path:"./images/nameBtn.png"},
{name:"cityview",path:"./images/cityview.png"},
{name:"btnImg-1",path:"./images/btnImg-1.png"},
{name:"btnImg-2",path:"./images/btnImg-2.png"},
{name:"btnImg-3",path:"./images/btnImg-3.png"},
{name:"btnImg-4",path:"./images/btnImg-4.png"},
{name:"bar-up",path:"./images/bar-up.png"},
{name:"bar-right-up",path:"./images/bar-right-up.png"},
{name:"bar-right-down",path:"./images/bar-right-down.png"},
{name:"bar-right",path:"./images/bar-left.png"},
{name:"bar-left-up",path:"./images/bar-left-up.png"},
{name:"bar-left-down",path:"./images/bar-left-down.png"},
{name:"bar-left",path:"./images/bar-left.png"},
{name:"bar-down",path:"./images/bar-down.png"}
];
var mouseObject = {x:0,y:0,isDown:false};
var list = [];
var clearList;
var datalist;//图片数据
var selectMap;//选择势力画面
var internalMap;//内政画面
var atkMap;//战斗画面
var selfList=[],enemyList=[],selfQuery,enemyQuery,selectCharacters = [];
//战斗画面 动作
var ACTION = {STAND:0,MOVE:1,ATTACK:2,DIE:3};
//战斗画面 所属
var BELONG = {SELF:0,ENEMY:1};
//战斗画面 方向
var DIRECTION = {RIGHT_UP:0,RIGHT:1,RIGHT_DOWN:2,DOWN:3,LEFT_DOWN:4,LEFT:5,LEFT_UP:6,UP:7};
//战斗画面 状态
var GAME_MODE = {NULL:null,SELECTING:"selecting",SELECTED:"selected"};
var gameStatus = {selectedIndex:0};
var now_mode = null;
//大地图数据
var mapData;

function main(){
	LGlobal.setDebug(true);
	loadingLayer = new LoadingSample3();
	addChild(loadingLayer);	
	LLoadManage.load(
		loadData,
		function(progress){
			loadingLayer.setProgress(progress);
		},
		function(result){
			LGlobal.setDebug(true);
			datalist = result;//将图片数据存入datalist数组
			removeChild(loadingLayer);
			loadingLayer = null;
			gameInit();
		}
	);
}